package com.yw.thesimpllestplayer;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;

import com.yw.thesimpllestplayer.adapter.BaseListAdapter;
import com.yw.thesimpllestplayer.adapter.MainAdapter;
import com.yw.thesimpllestplayer.bean.ClassBean;
import com.yw.thesimpllestplayer.ui.MediaExtractorActivity;
import com.yw.thesimpllestplayer.ui.SimplePlayerActivity;
import com.yw.thesimpllestplayer.util.ActivityUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * 制作一个最简单的视频播放器
 */
public class MainActivity extends BaseActivity {

    private ListView listView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initViews();

    }

    @Override
    public void videoPathCallback(String videoPath) {

    }


    private void initViews() {
        listView = findViewById(R.id.listView);
        List<ClassBean> datas = new ArrayList<>();
        datas.add(new ClassBean("MeidaExtractor使用案例", MediaExtractorActivity.class.getName()));
        datas.add(new ClassBean("最简单的视频播放器", SimplePlayerActivity.class.getName()));
        MainAdapter adapter = new MainAdapter(this, datas, new BaseListAdapter.OnListItemClickListener<ClassBean>() {
            @Override
            public void onItemClick(ClassBean data, int position) {
                ActivityUtil.getInstance().startActivity(MainActivity.this, data.getClassName());
            }
        });
        listView.setAdapter(adapter);
    }
}
